home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / util / pack / ULIB3954.lha / UnpackLib / Examples / NewExample2.S < prev   
Text File  |  1994-07-05  |  3KB  |  133 lines

  1. ; NEW Unpack.library Example #2: How To Make A Scan Routine
  2. ;
  3.  
  4.     INCDIR    "Includes1.3:Include1.3/"
  5.     INCLUDE    "Libraries/Dos_lib.i"
  6.     INCLUDE    "Exec/Exec_lib.i"
  7.  
  8.     INCDIR    "Includes3.0:Include3.0/"
  9.     INCLUDE    "Own/Unpack.i"
  10.  
  11.  
  12. START    move.l    4.w,a6
  13.     moveq    #0,d0
  14.     lea    dosname(pc),a1
  15.     jsr    _LVOOpenLibrary(a6)    ;Open Dos.library
  16.     move.l    d0,dosbase
  17.     beq    doserr
  18.  
  19.     moveq    #39,d0
  20.     lea    unpname(pc),a1
  21.     jsr    _LVOOpenLibrary(a6)    ;Open Unpack.library V39+
  22.     move.l    d0,unpbase
  23.     bne    unpok
  24.  
  25. ; Error While Opening The Unpack.library
  26.  
  27. UNPFAIL    move.l    dosbase(pc),a6
  28.     jsr    _LVOOutPut(a6)        ;Get The CLI Window File Handler
  29.  
  30.     move.l    d0,d1            ;File Handler
  31.     move.l    #unperrt,d2        ;Pointer To Error Text
  32.     moveq    #36,d3            ;Length Of Text
  33.     jsr    _LVOWrite(a6)        ;Write Text In Window
  34.     bra    unperr
  35.  
  36. ; Every Thing Are OK!
  37.  
  38. UNPOK    bsr    main            ;Jump To Main Routine
  39.  
  40.     move.l    4.w,a6
  41.     move.l    unpbase(pc),a1
  42.     jsr    _LVOCloseLibrary(a6)    ;Close Unpack.library
  43.  
  44. UNPERR    move.l    4.w,a6
  45.     move.l    dosbase(pc),a1
  46.     jsr    _LVOCloseLibrary(a6)    ;Close Dos.library
  47.  
  48. DOSERR    moveq    #0,d0
  49.     rts
  50. ;------------------------------------------------------------------------------
  51. ; Main Routine
  52. ;
  53. ; Returns the error number in D0 or 0
  54. ;
  55.  
  56. MAIN    move.l    unpbase(pc),a6
  57.     jsr    AllocCInfo(a6)        ;Allocate Cruncher Info Structure
  58.     move.l    d0,cinfo
  59.     beq    cinferr
  60.  
  61. ; Initialize Structure
  62.  
  63.     move.l    d0,a0
  64.     move.l    #arcpath,UI_Path(a0)
  65.     move.l    #scan,UI_Jump(a0)
  66.     move.b    #UFN_Delete,UI_Flag(a0)    ;NOTE: The Delete Flag Are Set
  67.  
  68.     lea    filnam(pc),a1        ;Pointer To A Filename
  69.     jsr    DetermineFile(a6)
  70.     beq    deterr            ;A Error!!!
  71.  
  72.     jsr    Unpack(a6)        ;Unpack The File
  73.     beq    loaderr
  74.     moveq    #0,d0
  75.     bra    unpacok
  76.  
  77. LOADERR
  78. DETERR1    move.w    UI_ErrorNum(a0),d0    ;Get Error Number
  79.  
  80. UNPACOK    move.l    cinfo(pc),a0
  81.     jsr    FreeCInfo(a6)        ;Free Cruncher Info Structure
  82. CINFERR    rts
  83.  
  84. ; Error Handling Routine For Determine
  85.  
  86. DETERR    cmp.w    #ERR_Determine,UI_ErrorNum(a0)
  87.     bne    deterr1
  88.  
  89.     jsr    LoadFile(a6)        ;Load The File
  90.     beq    loaderr
  91.     bsr    scan            ;Call Your Scan Routine
  92.     jsr    FreeFile(a6)        ;Free The File From Memory
  93.     moveq    #0,d0
  94.     bra    unpacok
  95. ;------------------------------------------------------------------------------
  96. ; The Scan Routine
  97. ;
  98.  
  99. SCAN    move.l    cinfo(pc),a0
  100.     move.l    UI_DecrunchAdr(a0),a1    ;Start Address Of Decrunched File
  101.     move.l    UI_DecrunchLen(a0),d0    ;Length Of Decrunched File
  102.     move.l    UI_CruncherName(a0),a2    ;Cruncher Name
  103.  
  104. ; This will only demostrate how to get the filename
  105.  
  106.     lea    filnam(pc),a3
  107.     tst.b    UI_UseFilenamePointer(a0)
  108.     beq    scan1
  109.     move.l    UI_LoadNamePoi(a0),a3
  110.  
  111. ; Just some simple flashing
  112.  
  113. SCAN1    move.w    #$8000,d7
  114. SCAN2    move.w    d7,d6
  115.     and.w    #$0fff,d6
  116.     move.w    d6,$dff180
  117.     dbra    d7,scan2
  118.     rts
  119. ;------------------------------------------------------------------------------
  120. DOSBASE    dc.l    0
  121. UNPBASE    dc.l    0
  122. CINFO    dc.l    0
  123. ;------------------------------------------------------------------------------
  124. DOSNAME    dc.b    "dos.library",0
  125. UNPNAME    dc.b    "unpack.library",0
  126. ;-----------------------------------------------------------------------------
  127. UNPERRT    dc.b    "You need the unpack.library V39+",10
  128. ARCPATH    dc.b    "RAM:",0        ;Enter Archive Path Here!!!
  129. FILNAM    dc.b    "DF0:CrunchedFile",0    ;Enter Filename Here!!!
  130.     even
  131. ;------------------------------------------------------------------------------
  132. SLUT
  133.